#pragma once
#include <iostream>
#include <unordered_map>

class CWHttpRequest
{
public:
    CWHttpRequest(const std::string &);
    ~CWHttpRequest() = default;
    std::string getRequestMethod() const { return m_method; }
    std::string getRequestURL() const { return m_URL; }
    std::string getRequestVersion() const { return m_version; }
    std::string getRequestBody() const { return m_body; }
    std::string getRequestHeader(const char *);
    std::string getRequestHeader(std::string &key) { return getRequestHeader(key.c_str()); }

private:
    // 解析请求行
    void parseRequestRow(const std::string &, size_t &);
    // 解析请求头
    void parseRequestHeader(const std::string &, size_t &);
    // 请求行
    std::string m_method, m_URL, m_version;
    // 请求头
    std::unordered_map<std::string, std::string> m_header;
    // 请求体
    std::string m_body;
};
